import {
    OrderStatus,
    OrderButtons
} from './define.js';
/**
 * 订单处理-买方
 */
const calcOrderActions = (order) => {
	//console.log(order)
    let statusTip = '',
        statusTipColor = '#40c282',
        statusActions = [],
        stutusDesc = '';
	if (order.Status == OrderStatus.RECEIVED && order.autonomy == 1){
		statusTip = '预约订单';
		// statusActions.push(OrderButtons.CancelRes)
		return {
		    text: statusTip,
		    color: statusTipColor,
		    actions: statusActions
		};
	}
	
	
	if (order.Status == OrderStatus.RECEIVE && order.isNurse == 1) {
		console.log(order.Status)
		console.log(order)
		//看订单主状态-待配送
		statusTip = '护理师待服务(可退款)';
		statusActions.push(OrderButtons.Receive)
		// statusActions.push(OrderButtons.apartRefund)
		// statusActions.push(OrderButtons.Refund);
		
		//statusActions.push(OrderButtons.CallPhone);
		return {
		    text: statusTip,
		    color: statusTipColor,
		    actions: statusActions
		};
	}
	
    //看订单主状态-待配供主体确认
    if (order.Status == OrderStatus.CONFIRM) {
        statusTip = '待配供企业确认';
        statusTipColor = '#40c282';
        stutusDesc = '亲，本单信息已经下达配供企业，请耐心等待配供企业确认。如有疑问，请点击下方联系服务企业';
        statusActions.push(OrderButtons.Cancel);
        statusActions.push(OrderButtons.CallPhone);
        return {
            text: statusTip,
            color: statusTipColor,
            actions: statusActions,
            desc: stutusDesc
        };
    } else if (order.Status == OrderStatus.CREATE) {
		//看订单主状态-待支付
		statusTip = '待支付';
		statusActions.push(OrderButtons.Pay);
		statusActions.push(OrderButtons.Cancel);
		return {
		    text: statusTip,
		    color: statusTipColor,
		    actions: statusActions
		};
	} else if (order.Status == OrderStatus.RECEIVE && order.IsRefund == 0) {
        //看订单主状态-待配送
        statusTip = '待服务(不可退款,服务全完成)';
		statusActions.push(OrderButtons.Receive)
		//statusActions.push(OrderButtons.Cancel);
        //statusActions.push(OrderButtons.CallPhone);
        return {
            text: statusTip,
            color: statusTipColor,
            actions: statusActions
        };
    } else if (order.Status == OrderStatus.RECEIVE && order.IsRefund == 1) {
		//看订单主状态-待配送
		statusTip = '待服务(可退款)';
		statusActions.push(OrderButtons.Refund);
		//statusActions.push(OrderButtons.CallPhone);
		return {
		    text: statusTip,
		    color: statusTipColor,
		    actions: statusActions
		};
	}else if(order.Status == OrderStatus.RECEIVE && order.IsRefund == 2){
		//看订单主状态-待配送
		statusTip = '待服务(不可退款,服务未全完成)';
		//statusActions.push(OrderButtons.Refund);
		//statusActions.push(OrderButtons.CallPhone);
		return {
		    text: statusTip,
		    color: statusTipColor,
		    actions: statusActions
		};
	}else if (order.Status == OrderStatus.DONE) {
        //看订单主状态-已完成
        statusTipColor = '#1B1B1B';
        statusTip = '已完成';
        //statusActions.push(OrderButtons.CallPhone);
        return {
            text: statusTip,
            color: statusTipColor,
            actions: statusActions
        };
    } else if (order.Status == OrderStatus.CANCEL) {
        //看订单主状态-已取消
        statusTipColor = '#1B1B1B';
        statusTip = '已取消';
        statusActions.push(OrderButtons.Delete);
        return {
            text: statusTip,
            color: statusTipColor,
            actions: statusActions,
        };
    } else {
        //其他状态
        return {
            text: statusTip,
            color: statusTipColor,
            actions: []
        };
    }
    //其他状态
    return {
        text: statusTip,
        color: statusTipColor,
        actions: []
    };
}



export default {
    calcOrderActions
}
